﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LabManager.Models;
using LabLibary;

namespace LabManager.Controller
{
    public class CauHinhController
    {
        CauHinhModel _cauHinhModel = new CauHinhModel();
        public List<ComportInfo> lstComportInfo = new List<ComportInfo>();
        
        public ComportInfo _comportInfo = new ComportInfo();

        public CauHinhController()
        {
            lstComportInfo = new List<ComportInfo>(new ComportInfo[8]);

            try
            {
                lstComportInfo = LoadConfig();

                int i = 0;
                foreach (ComportInfo _comInfo in lstComportInfo)
                {
                    lstComportInfo[i] = _comInfo;
                    i++;
                }
            }
            catch { }
        }


        public List<ComportInfo> LoadConfig()
        {
            return _cauHinhModel.LoadConfig();
        }


        public void Save(int _index=0)
        {
            lstComportInfo[_index] = _comportInfo;

            _cauHinhModel._lstComportInfo = lstComportInfo;
            _cauHinhModel.Save();
        }
    }
}
